﻿
Imports elpmis

Public Class cacheProcessor
    Inherits Global.cacheProcessor

    Private path As String = Nothing
    Private cache As Int64 = 0
    Private app As lpmsmonitor = Nothing

    Public Overrides Function pathidentity() As String
        Dim rtn As String = Nothing
        If lpmsmonitor.invokepath(app, rtn) Then
            Return rtn
        Else
            Return path
        End If
    End Function

    Protected Overrides Function normalRetiredTicks() As Int64
        Dim rtn As Int64 = Nothing
        If lpmsmonitor.invokecache(app, rtn) Then
            Return rtn
        Else
            Return cache
        End If
    End Function

    Public Overrides Sub initial(Optional ByVal config As configParser = Nothing)
        MyBase.initial(config)
        lpmsmonitor.invokeinitial(app, config)
    End Sub

    Protected Overrides Sub addresponseHeaders(ByVal context As httpContext)
        lpmsmonitor.invokeheader(app, context)
    End Sub

    Protected Overrides Function processImpl(ByVal context As httpContext) As Boolean
        Return lpmsmonitor.invokeprocess(app)
    End Function

    Public Sub New(ByVal path As String, ByVal cache As Int64, ByVal scriptfile As String)
        MyBase.New()
        copy(Me.path, path)
        copy(Me.cache, cache)
        app = New lpmsmonitor(scriptfile)
    End Sub
End Class
